package com.bangyu.monitor.modular.api;

import cn.stylefeng.roses.core.base.controller.BaseController;
import com.bangyu.monitor.modular.system.service.GetBinaryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Auther: zhangxue
 * @Date: 19/8/19 22:21
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/binary")
public class BinaryDataController extends BaseController {

    @Autowired
    private GetBinaryService getBinaryService;

    @RequestMapping("/open/{deviceNo}")
    public String open(@PathVariable("deviceNo") String deviceNo){

        getBinaryService.setOpen(true);
        getBinaryService.setDeviceNo(deviceNo);
        return "get"+getBinaryService.getDeviceNo()+" binary:"+getBinaryService.isOpen();
    }

    @RequestMapping("/close")
    public String close(){
        getBinaryService.close();
        return "get binary:"+getBinaryService.isOpen();
    }

    @RequestMapping("/isOpen")
    public String isOpen(){
        return ""+getBinaryService.isOpen();
    }



}
